﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace SharePoint.Contrib
{
    /// <summary>
    /// Utility class for working with types and assemblies
    /// </summary>
    /// <typeparam name="T">The type inside the assembly to work with</typeparam>
    public static class AssemblyManager<T>
    {
        /// <summary>
        /// Retrieves the fullname to the the typeof(T) (i.e. SharePoint.Contrib.AssemblyManager)
        /// </summary>
        public static string TypeFullName
        {
            get
            {
                Type type = typeof(T);
                return type.FullName;
            }
        }

        /// <summary>
        /// Retrieves a combination of TypeFullName and AssemblyFullName (i.e. SharePoint.Contrib.AssemblyManager, SharePoint.Contrib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx)
        /// </summary>
        public static string TypeAndAssemblyFullName
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", TypeFullName, AssemblyFullName);
            }
        }

        /// <summary>
        /// Retrieves full name of an assembly (i.e. SharePoint.Contrib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx)
        /// </summary>
        public static string AssemblyFullName
        {
            get
            {
                Type type = typeof(T);
                return type.Assembly.GetName().FullName;
            }
        }
    }


}
